﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class prefabScript : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        //给预制体按钮动态添加选中状态事件
        this.GetComponent<Button>().onClick.AddListener(delegate ()
        {
            Ctrl._ins.group_btn.GetComponent<SelectedGameObject>().setselected(gameObject.GetComponent<SelectedImage>());
        });
        //给预制体按钮添加发送对应对象的事件
        this.GetComponent<Button>().onClick.AddListener(delegate ()
        {
            for (int i = 0; i < Ctrl._ins.list_Yuanzhu.Count; i++)
            {//使用了预制体子对象Text的ID来确定是哪个对象
                if (this.transform.GetChild(3).GetComponent<Text>().text == Ctrl._ins.list_Yuanzhu[i].ID)
                {
                    if (Ctrl._ins.str_currentChengShi == "重庆市")
                    {
                        Ctrl._ins.list_Yuanzhu[i].标题 = Ctrl._ins.str_currentChengShi + Ctrl._ins.str_year + "对口支援项目详情";
                    }
                    else
                    {
                        Ctrl._ins.list_Yuanzhu[i].标题 = Ctrl._ins.str_year + "年" + Ctrl._ins.str_currentChengShi + "对口支援项目详情";
                    }
                    RRClient.ins.Send(DataTypeEnum.LScreenAndRScreen, OrderTypeEnum.JsonDataType, Ctrl._ins.list_Yuanzhu[i]);
                }
            }
            
        });

    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
